package coder.nav.controller;

import coder.nav.common.JwtToken;
import coder.nav.common.R;
import coder.nav.model.bo.NavLoginBO;
import coder.nav.model.vo.NavLoginVO;
import coder.nav.service.NavLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(tags = "登录接口")
@RestController
@RequestMapping
public class NavLoginController {

    @Autowired
    private NavLoginService loginService;

    @ApiOperation("执行登录")
    @PostMapping("/login")
    public R<NavLoginVO> login(@Validated @RequestBody NavLoginBO loginBO) {
        return new R<>(loginService.login(loginBO));
    }

    @ApiOperation("退出登录")
    @GetMapping("/logout")
    public R<Boolean> logout(@RequestParam("token") String token) {
        return new R<>(loginService.logout(token));
    }

    @ApiOperation("检查Token")
    @GetMapping("/login/checkToken")
    public R<Boolean> checkToken(@RequestParam("token") String token) {
        return new R<>(loginService.checkToken(token));
    }

}
